﻿Imports Publics
Module ModuleMethod
    Public Sub PhanQuyenMain()
        If Not vUser.KiemTraQuyen("01") AndAlso Not vUser.KiemTraQuyen("02") AndAlso Not vUser.KiemTraQuyen("03") AndAlso Not vUser.KiemTraQuyen("04") Then
            FrmMain.DockPanelMain.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden
            FrmMain.BarSubItem_BaoCao.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
            FrmMain.BarSubItem_DanhMuc.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
            FrmMain.BarSubItem_NhapLieu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
            FrmMain.MenuItemDoiMatKhau.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
            FrmMain.MenuItemNhapSoDuDauKyNguyenLieu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
            FrmMain.MenuItemCauHinhKetNoiDuLieu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
            FrmMain.MenuItemDangNhapVoiTaiKhoanKhac.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
            FrmMain.MenuItemQuanLiPhongBan.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
            FrmMain.MenuItemQuanLiTaiKhoanDangNhap.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
            FrmMain.MenuItemQuanLiQuyen.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
            FrmMain.MenuItemCaiDatPhimTat.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
        Else
            'Hệ thống
            If Not vUser.KiemTraQuyen("01") Then
                FrmMain.BarSubItem_HeThong.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                FrmMain.NBGHeThong.Visible = False
            Else
                 
                'Cấu hình kết nối CSDL
                If Not vUser.KiemTraQuyen("0103") Then
                    FrmMain.MenuItemCauHinhKetNoiDuLieu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemCauHinhKetNoiDuLieu.Visible = False
                End If
                If Not vUser.KiemTraQuyen("0104") Then
                    FrmMain.MenuItemDoiMatKhau.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemDoiMatKhau.Visible = False
                End If
                'Quản lí phòng ban
                If Not vUser.KiemTraQuyen("0105") Then
                    FrmMain.MenuItemQuanLiPhongBan.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemQuanLiPhongBan.Visible = False
                Else
                    HeThong.FrmDonVi.Them = IIf(vUser.KiemTraQuyen("010501"), True, False)
                    HeThong.FrmDonVi.Sua = IIf(vUser.KiemTraQuyen("010502"), True, False)
                    HeThong.FrmDonVi.Xoa = IIf(vUser.KiemTraQuyen("010503"), True, False)
                End If
                'Quản lí tài khoản đăng nhập
                If Not vUser.KiemTraQuyen("0106") Then
                    FrmMain.MenuItemQuanLiTaiKhoanDangNhap.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemQuanLiTaiKhoanDangNhap.Visible = False
                Else
                    HeThong.FrmTaiKhoan_NguoiSuDung.Them = IIf(vUser.KiemTraQuyen("010601"), True, False)
                    HeThong.FrmTaiKhoan_NguoiSuDung.Sua = IIf(vUser.KiemTraQuyen("010602"), True, False)
                    HeThong.FrmTaiKhoan_NguoiSuDung.Xoa = IIf(vUser.KiemTraQuyen("010603"), True, False)
                    HeThong.FrmTaiKhoan_NguoiSuDung.PPhanQuyen = IIf(vUser.KiemTraQuyen("010604"), True, False)

                End If
                'Quản lí quyền
                If Not vUser.KiemTraQuyen("0107") Then
                    FrmMain.MenuItemQuanLiQuyen.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemQuanLiQuyen.Visible = False
                End If
                'Cài đặt phím tắt
                If Not vUser.KiemTraQuyen("0108") Then
                    FrmMain.MenuItemCaiDatPhimTat.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemCaiDatPhimtat.Visible = False
                End If
                'Đăng nhập với tài khoản khác
                If Not vUser.KiemTraQuyen("0109") Then
                    FrmMain.MenuItemDangNhapVoiTaiKhoanKhac.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemDangNhapTaiKhoanKhac.Visible = False
                End If
                'Nhật ký hệ thống
                If Not vUser.KiemTraQuyen("0110") Then
                    FrmMain.MenuitemNhatKyHeThong.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemNhatKyHeThong.Visible = False
                End If
            End If

            '// Nhập liệu
            If Not vUser.KiemTraQuyen("02") Then
                FrmMain.BarSubItem_NhapLieu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                FrmMain.NBGNhapLieu.Visible = False
            Else
                'Bàn làm việc
                If Not vUser.KiemTraQuyen("0201") Then
                    FrmMain.MenuItemBanLamViec.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemBanLamViec.Visible = False
                End If
                 
                 
                'Tính tiêu hao nguyên liệu
                If Not vUser.KiemTraQuyen("0204") Then
                    FrmMain.MenuItemTieuHaoNguyenLieu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemTinhTieuHaoNguyenLieu.Visible = False
                End If
                'Tập hợp giá thành
                If Not vUser.KiemTraQuyen("0205") Then
                    FrmMain.MenuItemTapHopGiaThanh.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemTapHopGiaThanh.Visible = False
                End If
                'Xuất tiêu hao nguyên liệu
                If Not vUser.KiemTraQuyen("0206") Then
                    FrmMain.MenuItemXuatTieuHaoNguyenLieu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemXuatTieuHaoNguyenLieu.Visible = False
                End If
                'Phiếu nhập vật tư
                If Not vUser.KiemTraQuyen("0207") Then
                    FrmMain.MenuItemPhieuNhapVatTu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemPhieuNhapVatTu.Visible = False
                Else
                    NhapLieu.FrmVatTu.Them = IIf(vUser.KiemTraQuyen("020701"), True, False)
                    NhapLieu.FrmVatTu.Sua = IIf(vUser.KiemTraQuyen("020702"), True, False)
                    NhapLieu.FrmVatTu.Xoa = IIf(vUser.KiemTraQuyen("020703"), True, False)
                End If
                'Phiếu thu tiền mặt
                If Not vUser.KiemTraQuyen("0208") Then
                    FrmMain.MenuItemPhieuThuTienMat.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemPhieuThuTienMat.Visible = False
                Else
                    NhapLieu.FrmPhieuThuST.thempt = IIf(vUser.KiemTraQuyen("020801"), True, False)
                    NhapLieu.FrmPhieuThuST.thempt = IIf(vUser.KiemTraQuyen("020802"), True, False)
                    NhapLieu.FrmPhieuThuST.xoapt = IIf(vUser.KiemTraQuyen("020803"), True, False)
                    NhapLieu.FrmPhieuThuST.xempt = IIf(vUser.KiemTraQuyen("020804"), True, False)
                    NhapLieu.FrmPhieuThuST.inpt = IIf(vUser.KiemTraQuyen("020805"), True, False)

                End If
                'Phiếu phiếu chi tiền mặt
                If Not vUser.KiemTraQuyen("0209") Then
                    FrmMain.MenuItemPhieuThuTienMat.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemPhieuThuTienMat.Visible = False
                Else
                    NhapLieu.FrmPhieuThuST.thempc = IIf(vUser.KiemTraQuyen("020901"), True, False)
                    NhapLieu.FrmPhieuThuST.thempc = IIf(vUser.KiemTraQuyen("020902"), True, False)
                    NhapLieu.FrmPhieuThuST.xoapc = IIf(vUser.KiemTraQuyen("020903"), True, False)
                    NhapLieu.FrmPhieuThuST.xempc = IIf(vUser.KiemTraQuyen("020904"), True, False)
                    NhapLieu.FrmPhieuThuST.inpc = IIf(vUser.KiemTraQuyen("020905"), True, False)
                End If
            End If

            '// Danh mục
            If Not vUser.KiemTraQuyen("03") Then
                FrmMain.BarSubItem_DanhMuc.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                FrmMain.NBGDanhMuc.Visible = False
            Else
                 
                
                'Danh mục kho
                If Not vUser.KiemTraQuyen("0306") Or Not vUser.KiemTraQuyen("030604") Then
                    FrmMain.MenuItemDanhMucKho.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemDM_Kho.Visible = False
                Else
                    DanhMuc.FrmDMKho.Them = IIf(vUser.KiemTraQuyen("030601"), True, False)
                    DanhMuc.FrmDMKho.Sua = IIf(vUser.KiemTraQuyen("030602"), True, False)
                    DanhMuc.FrmDMKho.Xoa = IIf(vUser.KiemTraQuyen("030603"), True, False)
                    DanhMuc.FrmDMKho.SaoChep = IIf(vUser.KiemTraQuyen("030605"), True, False)
                End If
                'Danh mục khách hàng nhà cung cấp
                If Not vUser.KiemTraQuyen("0307") Or Not vUser.KiemTraQuyen("030704") Then
                    FrmMain.MenuItemDanhMucKhachHang.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemDM_KhachHang.Visible = False
                Else
                    DanhMuc.FrmDMKhachHang.Them = IIf(vUser.KiemTraQuyen("030701"), True, False)
                    DanhMuc.FrmDMKhachHang.Sua = IIf(vUser.KiemTraQuyen("030702"), True, False)
                    DanhMuc.FrmDMKhachHang.Xoa = IIf(vUser.KiemTraQuyen("030703"), True, False)
                    DanhMuc.FrmDMKhachHang.SaoChep = IIf(vUser.KiemTraQuyen("030705"), True, False)
                End If
                'Danh mục thành viên
                If Not vUser.KiemTraQuyen("0308") Or Not vUser.KiemTraQuyen("030804") Then
                    FrmMain.MenuItemDanhMucThanhVien.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemDM_ThanhVien.Visible = False
                Else
                    DanhMuc.FrmDMThanhVien.Them = IIf(vUser.KiemTraQuyen("030801"), True, False)
                    DanhMuc.FrmDMThanhVien.Sua = IIf(vUser.KiemTraQuyen("030802"), True, False)
                    DanhMuc.FrmDMThanhVien.Xoa = IIf(vUser.KiemTraQuyen("030803"), True, False)
                    DanhMuc.FrmDMThanhVien.SaoChep = IIf(vUser.KiemTraQuyen("030805"), True, False)
                End If
                'Danh mục tính chất nhập xuất
                If Not vUser.KiemTraQuyen("0309") Or Not vUser.KiemTraQuyen("030904") Then
                    FrmMain.MenuItemDanhMucTCNX.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemDM_TCNX.Visible = False
                Else
                    DanhMuc.FrmDMTCNX.Them = IIf(vUser.KiemTraQuyen("030901"), True, False)
                    DanhMuc.FrmDMTCNX.Sua = IIf(vUser.KiemTraQuyen("030902"), True, False)
                    DanhMuc.FrmDMTCNX.Xoa = IIf(vUser.KiemTraQuyen("030903"), True, False)
                    DanhMuc.FrmDMTCNX.SaoChep = IIf(vUser.KiemTraQuyen("030905"), True, False)
                End If
                'Danh mục nhóm vật tư
                If Not vUser.KiemTraQuyen("0310") Or Not vUser.KiemTraQuyen("031004") Then
                    FrmMain.MenuItemDanhMucNhomVatTu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemDM_NhomVatTu.Visible = False
                Else
                    DanhMuc.FrmDMNhomVatTu.Them = IIf(vUser.KiemTraQuyen("031001"), True, False)
                    DanhMuc.FrmDMNhomVatTu.Sua = IIf(vUser.KiemTraQuyen("031002"), True, False)
                    DanhMuc.FrmDMNhomVatTu.Xoa = IIf(vUser.KiemTraQuyen("031003"), True, False)
                    DanhMuc.FrmDMNhomVatTu.SaoChep = IIf(vUser.KiemTraQuyen("031005"), True, False)
                End If
                'Danh mục vật tư
                If Not vUser.KiemTraQuyen("0311") Or Not vUser.KiemTraQuyen("031104") Then
                    FrmMain.MenuItemDanhMucVatTu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemDM_NhomVatTu.Visible = False
                Else
                    DanhMuc.FrmDMVatTu.Them = IIf(vUser.KiemTraQuyen("031101"), True, False)
                    DanhMuc.FrmDMVatTu.Sua = IIf(vUser.KiemTraQuyen("031102"), True, False)
                    DanhMuc.FrmDMVatTu.Xoa = IIf(vUser.KiemTraQuyen("031103"), True, False)
                    DanhMuc.FrmDMVatTu.SaoChep = IIf(vUser.KiemTraQuyen("031105"), True, False)
                End If
            End If
            '// Báo cáo
            If Not vUser.KiemTraQuyen("04") Then
                FrmMain.BarSubItem_BaoCao.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                FrmMain.NBGBaoCao.Visible = False
            Else
                'Báo cáo theo thời gian trong ngày
                If Not vUser.KiemTraQuyen("0401") Then
                    FrmMain.MenuItemBaoCaoTheoThoiGianTrongNgay.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemBC_TheoThoiGianTrongNgay.Visible = False
                End If
                'Báo cáo xuất kho
                If Not vUser.KiemTraQuyen("0402") Then
                    FrmMain.MenuItemBaoCaoXuatKho.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemBC_XuatKho.Visible = False
                End If
                'Báo cáo nhập xuất tồn vật tư
                If Not vUser.KiemTraQuyen("0403") Then
                    FrmMain.MenuItemBaoCaoNXTVatTu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemBC_NXTVatTu.Visible = False
                End If
                'Báo cáo nhập xuất tồn nguyên liệu
                If Not vUser.KiemTraQuyen("0404") Then
                    FrmMain.MenuItemBaoCaoNXTNguyenLieu.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemBC_NXTNguyenLieu.Visible = False
                End If
                'Báo cáo tổng hợp công nợ
                If Not vUser.KiemTraQuyen("0405") Then
                    FrmMain.MenuItemBaoCaoTongHopCongNo.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    FrmMain.NBItemBC_TongHopCongNo.Visible = False
                End If
            End If
        End If
    End Sub
End Module
